package adapter.power;

public interface DC5Adapter {

	/**
	 * 检查输入电压是否满足
	 * 
	 * @param ac
	 * @return
	 */
	boolean support(AC ac);

	/**
	 * 将输入电压转为5V直流输出
	 * 
	 * @param ac
	 * @return
	 */
	int outputDC5V(AC ac);

}

class ChinaPowerAdapter implements DC5Adapter {

	private int voltage = 220;

	@Override
	public boolean support(AC ac) {
		return voltage == ac.outputAC();
	}

	@Override
	public int outputDC5V(AC ac) {

		int input = ac.outputAC();

		int output = input / 44;

		System.out.println("使用中国电源适配器，输入AC:" + input + "V,输出DC:" + output + "伏");

		return output;
	}

}

class JapanPowerAdapter implements DC5Adapter {

	private int voltage = 110;

	@Override
	public boolean support(AC ac) {
		return voltage == ac.outputAC();
	}

	@Override
	public int outputDC5V(AC ac) {
		int input = ac.outputAC();

		int output = input / 22;

		System.out.println("使用日本电源适配器，输入AC:" + input + "V,输出DC:" + output + "伏");

		return output;
	}

}